package com.frxuexi.lib_base.base

import androidx.lifecycle.viewModelScope
import com.frxuexi.lib_base.bean.ApiResponse
import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.SharedFlow
import kotlinx.coroutines.launch
import java.lang.Error
import java.lang.Exception

class BaseAppViewModel:BaseViewModel<Unit>() {
    private val _exception=MutableSharedFlow<Exception>()
    val exception:SharedFlow<Exception>
        get() = _exception

    private val _error=MutableSharedFlow<ApiResponse<*>>()
        val error:SharedFlow<ApiResponse<*>>
        get() = _error

    fun emitException(exception: Exception){
        viewModelScope.launch {
            _exception.emit(exception)
        }
    }

    fun emitError(apiResponse: ApiResponse<*>){
        viewModelScope.launch {
            _error.emit(apiResponse)
        }
    }
}